package edit;

import java.awt.Dimension;
import java.awt.Toolkit;

import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTextField;

public class RulePane extends JScrollPane{
	private JPanel panel;
	private JRadioButton inputBtn;
	private JRadioButton outputBtn;
	private JComboBox category;
	private JTextField groupName;
	private JTextField ruleName;
	private JButton triggerWordBtn;
	private JComboBox triggerWord;
	private String title;
	
	public RulePane(String title){
		this.title = title;
		this.setBorder(BorderFactory.createTitledBorder(this.title));
		panel = new JPanel();  
		setViewportView(panel);
		panel.setLayout(null);
		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
		double width = screenSize.getWidth();
		double height = screenSize.getHeight();
		int palettewidth = (int)(width*0.4);
		int paletteheight = (int)(height*0.15);
		this.setPreferredSize(new Dimension(palettewidth,paletteheight));
		addComponents();
	}
	
	public void addComponents(){
		JLabel catLbl = new JLabel("Syntactic Category: ");
		JLabel groupLbl = new JLabel("Group Name: ");
		JLabel ruleLbl = new JLabel("Rule's Name: ");
		
		category = new JComboBox();
		groupName = new JTextField("");
		ruleName = new JTextField("");
		
		catLbl.setBounds(5, 5, 140, 20);
		category.setBounds(140, 5, 120, 20);
		
		triggerWordBtn = new JButton("Trigger Word");
		triggerWord = new JComboBox();
		triggerWordBtn.setBounds(270, 5, 100, 20);
		triggerWord.setBounds(380, 5, 150, 20);
		
		groupLbl.setBounds(5, 30, 120, 20);
		groupName.setBounds(140, 30, 120, 20);
		ruleLbl.setBounds(270, 30, 120, 20);
		ruleName.setBounds(380, 30, 120, 20);
		
		inputBtn = new JRadioButton("Input Structure");
		outputBtn = new JRadioButton("Output Structure");
		
		ButtonGroup bgroup = new ButtonGroup();
		bgroup.add(inputBtn);
		bgroup.add(outputBtn);
		inputBtn.setBounds(5, 55, 120, 20);
		outputBtn.setBounds(130, 55, 120, 20);
		
		panel.add(catLbl);
		panel.add(groupLbl);
		panel.add(ruleLbl);
		panel.add(category);
		panel.add(groupName);
		panel.add(ruleName);
		panel.add(triggerWordBtn);
		panel.add(triggerWord);
		panel.add(inputBtn);
		panel.add(outputBtn);
	}
	
}
